package com.whopxx.domain.vo;

import com.whopxx.enums.BizCodeEnum;
import lombok.Data;

@Data
public class ResultVO<T> {
    private Boolean success;
    private String message;
    private Integer code;
    private T data;

    public static <T> ResultVO<T> success(T data) {
        ResultVO<T> resultVo = new ResultVO<>();
        resultVo.setSuccess(true);
        resultVo.setData(data);
        resultVo.setCode(BizCodeEnum.SUCCESS.getCode());
        return resultVo;
    }
    public static <T> ResultVO<T> success() {
        ResultVO<T> resultVo = new ResultVO<>();
        resultVo.setSuccess(true);
        resultVo.setCode(BizCodeEnum.SUCCESS.getCode());
        return resultVo;
    }

    public static <T> ResultVO<T> fail(T data) {
        ResultVO<T> resultVo = new ResultVO<>();
        resultVo.setSuccess(false);
        resultVo.setData(data);
        resultVo.setCode(BizCodeEnum.UNKNOWN_EXCEPTION.getCode());
        return resultVo;
    }
    public static <T> ResultVO<T> fail() {
        ResultVO<T> resultVo = new ResultVO<>();
        resultVo.setSuccess(false);
        resultVo.setCode(BizCodeEnum.UNKNOWN_EXCEPTION.getCode());
        return resultVo;
    }

}
